﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BDS3M.Controls
{
    public partial class BoxChiTietSanGiaoDich : System.Web.UI.UserControl
    {

        public string sgdngaycapnhat;
        public string sgddientich;
        public string sgdkhuvuc;
        public string sgdcautruc;
        public string sgdgiaban;
        public string sgdthongtinchitiet;
        public string sgdwebsite;
        public string sgdmayban;
        public string sgddidong;

        public string eleid;
        public string eleusername;
        public string elefullname;
        public string elediachi;
        public string eledienthoai;
        public string eleemail;
        public string eledidong;
        public string elecongty;

        public string idquanhuyen;
        public string quanhuyen;

        public string idtinhthanhpho;
        public string tinhthanhpho;
  

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                DataTable dt = ChiTietSanGiaoDich.dt;

                sgdngaycapnhat = dt.Rows[0]["SanGiaoDich_Date"].ToString();  
                sgddientich = dt.Rows[0]["SanGiaoDich_DienTich"].ToString();
                sgdkhuvuc = dt.Rows[0]["SanGiaoDich_KhuVuc"].ToString();
                sgdcautruc = Server.HtmlDecode(dt.Rows[0]["SanGiaoDich_CauTruc"].ToString());
                sgdgiaban = dt.Rows[0]["SanGiaoDich_GiaBan"].ToString();
                sgdthongtinchitiet = Server.HtmlDecode(dt.Rows[0]["SanGiaoDich_TTChiTiet"].ToString());
                sgdwebsite = dt.Rows[0]["SanGiaoDich_Website"].ToString();
                sgdmayban = dt.Rows[0]["SanGiaoDich_MayBan"].ToString();
                sgddidong = dt.Rows[0]["SanGiaoDich_DiDong"].ToString();

                elefullname = dt.Rows[0]["SanGiaoDich_Ten"].ToString();
                elediachi = dt.Rows[0]["SanGiaoDich_DiaChi"].ToString();
                eledienthoai = dt.Rows[0]["SanGiaoDich_MayBan"].ToString();
                eleemail = dt.Rows[0]["SanGiaoDich_Email"].ToString();
                eledidong = dt.Rows[0]["SanGiaoDich_DiDong"].ToString();
                elecongty = dt.Rows[0]["SanGiaoDich_TenCongTy"].ToString();

                eleid = dt.Rows[0]["Employee_ID"].ToString();

                idtinhthanhpho = dt.Rows[0]["TinhThanhPho_ID"].ToString();

                idquanhuyen = dt.Rows[0]["QuanHuyen_ID"].ToString();


                DataTable dte = DAL.DCollector.DBCollector.Instance.StoredSelectAllTableWhereID("tbl_Employee", "Employee_ID", eleid.ToString());
                eleusername = dte.Rows[0]["Employee_User"].ToString();
  

                DataTable dtt = DAL.DCollector.DBCollector.Instance.StoredSelectAllTableWhereID("tbl_TinhThanhPho", "TinhThanhPho_ID", idtinhthanhpho.ToString());
                tinhthanhpho = dtt.Rows[0]["TinhThanhPho_Ten"].ToString();

                DataTable dtq = DAL.DCollector.DBCollector.Instance.StoredSelectAllTableWhereID("tbl_QuanHuyen", "QuanHuyen_ID", idquanhuyen.ToString());
                quanhuyen = dtq.Rows[0]["QuanHuyen_Ten"].ToString();

                //Load Tien Ich

                rpt_DanhMucTienIch.DataSource = DAL.DCollector.DBCollector.Instance.CallStored("callstored","Select DanhMucTienIch_Name,DanhMucTienIch_Image  from tbl_SanGiaoDich AS SGD,tbl_DanhMucTienIch AS DMTI,tbl_TienIch AS TI Where SGD.SanGiaoDich_ID ="+ Convert.ToInt32(Request.QueryString["ID"]) +" AND DMTI.DanhMucTienIch_ID = TI.DanhMucTienIch_ID AND TI.SanGiaoDich_ID = SGD.SanGiaoDich_ID", true);
                rpt_DanhMucTienIch.DataBind();

            }
        }
    }
}